<?php

/**
 * Layout Admin - LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    19-apr-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<!DOCTYPE html>
<html>
    <head>
	<link rel="shortcut icon" href="logo.ico" type="image/x-icon" />
	<link rel="icon" href="logo.ico" type="image/x-icon" />
	<title>Admin - </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- CSS -->
	<link rel="stylesheet" href="/css/admin/structure.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/form.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/theme.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/navigation.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/jquery-ui-1.8.18.custom.css" type="text/css" />
	<link rel="stylesheet" href="/css/admin/pagination.css" type="text/css" />

<!--	<link rel="stylesheet" href="/css/shadowbox.css" type="text/css" />-->

	<link rel="stylesheet" href="/css/jquery.fancybox-1.3.4.css" type="text/css" />

	<!-- JavaScript -->
<!--	<script type="text/javascript" src="/js/jquery-1.5.1.min.js"></script>-->
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<!--        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>-->
        
	<script type="text/javascript" src="/js/jquery.metadata.js"></script>

	<script type="text/javascript" src="/js/jquery.mypagination.js"></script>
	
	<script type="text/javascript" src="/js/jquery.fancybox-1.3.4.pack.js"></script>
	
        <!-- Localizzazione Calendario -->
<!--        <script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-it.js"></script>-->
<!--<script type="text/javascript" src="/js/fab.js"></script>
	<script type="text/javascript" src="/js/cufon-yui.js"></script>
	<script type="text/javascript" src="/js/cufon-marketingscript.js"></script>
	<script type="text/javascript" src="/js/script.js"></script>-->
	<!--	<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.js"></script>-->
	<!-- required plugins -->
	<script type="text/javascript" src="/js/jquery-ui-1.8.20.custom.min.js"></script>
	<script type="text/javascript" src="/js/jquery.validate.min.js"></script>

        <script type="text/javascript" src="/js/qtip/jquery.qtip.min.js"></script>
        <link rel="stylesheet" href="/css/jquery.qtip.min.css" type="text/css" />
	<!--[if IE]><script type="text/javascript" src="/js/jquery.bgiframe.js"></script><![endif]-->
        
        
<script type="text/javascript">
    //<![CDATA[
    // Validazione di default...
    var validator;
    $(document).ready(function() {
        // consente di agganciare tag tipo: validate="required:true"
        //$.metadata.setType("attr", "validate");
        
        // consente di agganciare tag tipo: validate="required:true"
        //$.metadata.setType("class", "ref");
        
        $.datepicker.setDefaults( $.datepicker.regional[ "it" ] );
        $.validator.setDefaults({
	    invalidHandler: function(form, validator) {
		var errors = validator.numberOfInvalids();
                //console.log(errors);
		if (errors) {
		    $("li#errorLi").show();
		} else {
		    $("li#errorLi").hide();
		};
	    },
	    
	    // Assegna classe 'error' al <li> dell'elemento invalido
	    errorPlacement: function(error, element) {
		//console.log(element);
		element.parent("span").parent("div").parent("li").addClass("error");
		error.appendTo( element.parent("span").parent("div"));
	    },
	    submitHandler: function(form) {
		//$('#salva').attr('disabled', 'disabled');

		form.submit();
	    },
	    errorElement: "p",
	    debug:true
	});
        
	validator = $("form.fab").validate();     
        
	// a custom method for validating the date range
//	$.validator.addMethod("validDate", function(value, element, classname) {
//            console.log(element);
//	    if($("#day").val() == '' && $("#month").val() == '' && $("#year").val() == '')
//		return false;
//	
//	    try{$.datepicker.parseDate('ddmmyy', $("#day").val()+$("#month").val()+$("#year").val() );return true;}
//	    catch(e){ console.log(e); return false;}
//
//	}, "<?php echo ERR_DATE ?>");             
//        
//	// Date facoltative
//	$.validator.addMethod("validDateOptional", function(value, element, classname) {
//	    if($("#day_opt").val() == '' && $("#month_opt").val() == '' && $("#year_opt").val() == '')
//		return true;
//	
//	    try{$.datepicker.parseDate('ddmmyy', $("#day_opt").val()+$("#month_opt").val()+$("#year_opt").val() );return true;}
//	    catch(e){ console.log(e); return false;}
//
//	}, "<?php echo ERR_DATE ?>"); 

	$.validator.addMethod("validDate", function(value, element, classname) {
	    // Ottieni il valore del name del campo...poi aggiungi _d, _m, _y
            var name = element.name.substr(0, element.name.length - 1);
            
	    if($("#"+name+"d").val() == '' && $("#"+name+"m").val() == '' && $("#"+name+"y").val() == '')
		return false;
            
            try{$.datepicker.parseDate('ddmmyy', $("#"+name+"d").val()+$("#"+name+"m").val()+$("#"+name+"y").val() );return true;}
	    catch(e){ console.log(e); return false;}

	}, "<?php echo ERR_DATE ?>");  

	$.validator.addMethod("validDateOptional", function(value, element, classname) {
	    // Ottieni il valore del name del campo...poi aggiungi _d, _m, _y
            var name = element.name.substr(0, element.name.length - 1);

	    if($("#"+name+"d").val() == '' && $("#"+name+"m").val() == '' && $("#"+name+"y").val() == '')
		return true;
            
            try{$.datepicker.parseDate('ddmmyy', $("#"+name+"d").val()+$("#"+name+"m").val()+$("#"+name+"y").val() );return true;}
	    catch(e){ console.log(e); return false;}

	}, "<?php echo ERR_DATE ?>");  
        
        $.validator.addMethod("ckeditor", function(value, element) { 
            var textData = CKEDITOR.instances[element.id].getData();
            if(textData.trim().length>0) return true;
            return false;
        }, "No data in editor");        
        
	// a new class rule to group all three methods
	$.validator.addClassRules({
	    dateValid: {validDate:true}
	});
        
	$.validator.addClassRules({
	    dateValidOptional: {validDateOptional:true}
	});
//	$.validator.addClassRules({
//	    editor: {ckeditor:true}
//	});

        // Effetto Focus...(aggiunge sfondo giallo ai campi)
        $('form ul li :input').focus(function() {
            $('form ul li').removeClass('focused');
            $(this).closest('li').addClass('focused');
        });
        
        $('form ul li :input').focusout(function() {
            $(this).closest('li').removeClass('focused');
        });
        
        $('tr[class^="selectable"]').click(function(){
            $(this).siblings().removeClass('selected');
            $(this).toggleClass('selected');
        })        
    });
        

    //]]>
</script>        
    </head>
    <body id="public">
	<!--	<div id="header">
	    HEader
	</div>-->
	<div id="container">
	    <div id="nav">
<!--		<h1 class="logo"><span>La Fabbrica</span></h1>-->
		<div class="tabs">
		    <ul id="menu" class="clearfix">
			<li class="idx">
			    <a class="<?php echo $this->controller == 'index' ? 'active' : ''?>" href="/admin/" title="Form Manager">Home</a>
			</li>
			<li class="pst">
			    <a class="<?php echo $this->controller == 'posts' ? 'active' : ''?>" href="/admin/posts" title="Report Manager">Post</a>
			</li>
			<li class="art">
			    <a class="<?php echo $this->controller == 'artisti' ? 'active' : ''?>" href="/admin/artisti" title="Report Manager">Artisti</a>
			</li>
			<li class="ctc">
			    <a class="<?php echo in_array( $this->controller, array( 'contatti' ) ) ? 'active' : ''?>" href="/admin/contatti/rubrica" title="User Management">Rubrica</a>
			</li>
			<li class="bkn">
			    <a class="<?php echo in_array( $this->controller, array( 'booking', 'attivita' ) ) ? 'active' : ''?>" href="/admin/booking/" title="User Management">Booking</a>
			</li>
			<li class="cpl">
			    <a class="<?php echo in_array( $this->controller,  array( 'gestione', 'location', 'partners' ) ) ? 'active' : ''?>" href="/admin/gestione" title="Report Manager">Gestione</a>
			</li>
<!--			<li class="usr">
			    <a class="<?php echo $this->controller == 'utenti' ? 'active' : ''?>" href="/admin/utenti" title="User Management">Utenti</a>
			</li>
			<li class="lcn">
			    <a class="<?php echo $this->controller == 'location' ? 'active' : ''?>" href="/admin/location" title="User Management">Locations</a>
			</li>
			<li class="prt">
			    <a class="<?php echo $this->controller == 'partners' ? 'active' : ''?>" href="/admin/partners" title="User Management">Partner</a>
			</li>-->
			<li class="lgo">
			    <a href="#" class="lbOn" title="Logout!">Logout</a>
			</li>
		    </ul>
		    <br style="clear:both" />
		</div><!--nav-->
	    </div>
	    
	    <?php echo $this->content ?>
	</div>
	<img id="bottom" src="/images/admin/bottom.png" alt="" />
    </body>
</html>